//
//  MainController02.m
//  PosApp
//
//  Created by 刘萍 on 2018/8/31.
//  Copyright © 2018年 李英新. All rights reserved.
//

#import "MainController02.h"
#import "TwoMainHeadView.h"
#import "TwoMainViewCell.h"

#import "NewsViewController.h"
#import "AddXYCardController.h"
#import "CheckNewsController.h"



@interface MainController02 ()<UITableViewDelegate,UITableViewDataSource,TwoMainHeadViewDelegate>

@property (weak, nonatomic) IBOutlet UIView *MainBackView02;
@property (strong, nonatomic) IBOutlet UILabel *NumbLabel;

@property (weak, nonatomic) IBOutlet UITableView *MainTable02;

@end

@implementation MainController02

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:animated];
    
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    self.NumbLabel.layer.cornerRadius = self.NumbLabel.bounds.size.height/2;
    self.NumbLabel.layer.masksToBounds = YES;
    
    
    CAGradientLayer *gl = [CAGradientLayer layer];
    gl.frame = CGRectMake(0,0,KScreenW,350);
    gl.startPoint = CGPointMake(0, 0);
    gl.endPoint = CGPointMake(1, 1);
    gl.colors = @[(__bridge id)[UIColor colorWithRed:255/255.0 green:109/255.0 blue:1/255.0 alpha:1].CGColor,(__bridge id)[UIColor colorWithRed:251/255.0 green:41/255.0 blue:67/255.0 alpha:1].CGColor];
    gl.locations = @[@(0.0),@(1.0f)];
    [self.MainBackView02.layer addSublayer:gl];
    
    
    self.MainTable02.rowHeight = 190;
    self.MainTable02.delegate = self;
    self.MainTable02.dataSource = self;
    self.MainTable02.backgroundColor = [UIColor clearColor];
    self.MainTable02.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.MainTable02 registerNib:[UINib nibWithNibName:@"TwoMainViewCell" bundle:nil] forCellReuseIdentifier:@"cell"];
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 5;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    TwoMainViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[TwoMainViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    [cell CreateTwoMainViewCell];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    CheckNewsController * NewsC = [[CheckNewsController alloc] init];
    [self.navigationController pushViewController:NewsC animated:YES];
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 200;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    TwoMainHeadView * headV = [[NSBundle mainBundle] loadNibNamed:@"TwoMainHeadView" owner:self options:nil][0];
    headV.delegate = self;
    [headV CreateTwoMainHeadView];
    return headV;
}

- (void)ClickOnBtnOfTwoMainHeadViewToAddNewCard{
    AddXYCardController * AddC = [[AddXYCardController alloc] init];
    [self.navigationController pushViewController:AddC animated:YES];
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.1;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView * footV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenW, 0.1)];
    return footV;
}
- (IBAction)ClickOnLeftBtnOfMainController02:(id)sender {
    
    NewsViewController * newsC = [[NewsViewController alloc] init];
    [self.navigationController pushViewController:newsC animated:YES];
}

- (IBAction)ClickOnrightBtnOfMainController02:(id)sender {
    [MBProgressHUD showAlertViewWithText:@"数据重新排序中"];
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
